<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('项目详情')"/>
    <th:block th:include="include :: select2-css"/>
</head>

<body>
<div class="main-content">
    <form class="form-horizontal" id="form-user-edit" th:object="${workshopNowClass}">

        <!-- [[${item}]]-->

        <input name="lineId" type="hidden" th:field="*{lineId}"/>

        <!--                <h4 class="form-header h4">基本信息</h4>-->
        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">当前车间班组id：</label>
                    <div class="col-sm-8">
                        <input name="classgroupNowNumber" th:field="*{classgroupNowNumber}" placeholder="请输入当前车间班组id"
                               class="form-control" type="text" maxlength="30"
                        >
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">当前车间班次名称：</label>
                    <div class="col-sm-8">
                        <input id="classgroupNowName" name="classgroupNowName" th:field="*{classgroupNowName}"
                               placeholder="请输入当前车间班次名称" class="form-control"
                               type="text" maxlength="30">
                    </div>
                </div>
            </div>

        </div>

        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">入库单主表id：</label>
                    <div class="col-sm-8">
                        <input id="stockinGuid" name="stockinGuid" th:field="*{stockinGuid}" placeholder="请输入入库单主表id"
                               class="form-control" type="text"
                               maxlength="30">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">车间班次状态：</label>
                    <div class="col-sm-8">
                        <input id="classNowStatus" name="classNowStatus" th:field="*{classNowStatus}"
                               placeholder="请输入车间班次状态" class="form-control" type="text"
                               maxlength="30">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">班次（日期）：</label>
                    <!--                        <input name="prjgroupId" type="hidden" id="prjgroupId" th:field="*{prjgroupId}"/>-->
                    <div class="col-sm-8">
                        <input id="dataTime" name="dataTime" th:field="*{dataTime}" placeholder="请输入班次（日期）"
                               class="form-control" type="text"
                               maxlength="30">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">生产线的喷码机编号：</label>
                    <div class="col-sm-8">
                        <input id="pmNumber" name="pmNumber" th:field="*{pmNumber}" placeholder="请输入生产线的喷码机编号"
                               class="form-control" type="text"
                               maxlength="30">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">生产线的喷码伪验码号：</label>
                    <div class="col-sm-8">
                        <input id="wId" name="wId" th:field="*{wId}" placeholder="请输入生产线的喷码伪验码号" class="form-control"
                               type="text"
                               maxlength="30">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">计划guid：</label>
                    <div class="col-sm-8">
                        <input id="barcodeGuid" name="barcodeGuid" th:field="*{barcodeGuid}" placeholder="请输入计划guid"
                               class="form-control" type="text"
                               maxlength="30">
                    </div>
                </div>
            </div>
        </div>


        <!--<h4 class="form-header h4">其他信息</h4>-->
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-xs-2 control-label">备注：</label>
                    <div class="col-xs-10">
                        <textarea name="remark" maxlength="500" th:field="*{remark}" class="form-control"
                                  rows="3"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script type="text/javascript">
    var prefix = ctx + "bas/workshopNowClass";


    function submitHandler() {
        var data = $("#form-user-edit").serializeArray();
        console.log(data)
        //TODO 如果沒有选择项目组（项目组为空 不允许提交）
        $.operate.save(prefix + "/edit", data);
    }

    /* 用户管理-修改-选择部门树 */
    function selectDeptTree() {
        var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
        var url = ctx + "system/dept/selectDeptTree/" + deptId;
        var options = {
            title: '选择部门',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        var body = layer.getChildFrame('body', index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        selectgroups();
        layer.close(index);
    }

    $(function () {
        $('#post').select2({
            placeholder: "请选择岗位",
            allowClear: true
        });
    })

    //分配项目组
    function selectgroups() {
        var deptId = $("#treeId").val();
        var url = ctx + "system/item/selectPrjgroupByDeptId/" + deptId;
        $.get(url, function (result) {
            console.log(result)
            var html = ""
            if (result.length > 0) {
                for (var i = 0; i < result.length; i++) {
                    html += "<option  value=" + result[i].prjgroupId + ">" + result[i].prjgroupName + "</option>"
                }
            }

            $("#prjGroup").html(html)
        })

    }
</script>
</body>
</html>